getCSPGroupPattern <- function (groupcode, Pversion=0, daysbefore=40, daysafter=20, Sappend=".vadb") {
  groupinfo <- getDBGroup(groupcode)  # retrieve table with stock_id, code, from, to
  getSymbolsGroup(groupcode, daysbefore=daysbefore, daysafter=daysafter)  # retrieve data from group members into workspace
  
  pattern <- list()
  for (i in 1:length(groupinfo[,"code"])) {
    # the list item is named after the symbol code
    # the right version of getCSPPattern is called. default is 0, the schoolbook version
    # example: x <- getCSPPattern0(C.vadb, "1990-01-01", "2000-01-01")
    pattern[[groupinfo[,"code"][i]]] <- 
      get( paste('getCSPPattern', Pversion, sep="") ) ( get(paste(groupinfo[,"code"][i], Sappend, sep="")), groupinfo[,"from"][i], groupinfo[,"to"][i])
  }
  return(pattern)
}
